home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / RCS / mkmf.test,v < prev    next >
Text File  |  1989-10-10  |  5KB  |  238 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.3
  10. date     89.10.09.21.28.21;  author rab;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     88.04.28.13.24.19;  author ouster;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     88.03.18.15.10.45;  author deboor;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @Subscript for test program source directories
  27. @
  28.  
  29.  
  30. 1.3
  31. log
  32. @Modifications for distribution.
  33. @
  34. text
  35. @#!/bin/csh -f
  36. #
  37. # A script to generate (or regenerate) the Makefile for a test directory.
  38. # If ./Makefile.proto exists, use it, else use a common prototype.
  39. #
  40. # We assume we were invoked from mkmf, thus we don't need to alter the
  41. # path, and MKMFDIR is in the environment to tell us where to find prototype
  42. # makefiles, etc.
  43. #
  44. # Variables:
  45. #    prog        program to create (directories are assumed to be named
  46. #            after the programs they create)
  47. #    pref        prefix pattern that files must match to be included
  48. #    makefile    name of the makefile to create
  49. #    MKMFDIR        directory containing prototype makefiles
  50. #
  51. set prog=$cwd:t
  52. set pref='[a-z_A-Z]'
  53.  
  54. if ($?MAKEFILE) then
  55.     set makefile=$MAKEFILE
  56. else
  57.     set makefile=Makefile
  58. endif
  59.  
  60. set distdir=($DISTDIR)
  61.  
  62. if (-e $makefile.proto) then
  63.     set proto=$makefile.proto
  64. else
  65.     set proto="${MKMFDIR}/Makefile.test"
  66. endif
  67.  
  68. echo "Generating a Makefile for $prog using $proto"
  69.  
  70. #
  71. # First figure out what's there by way of .c, .y, .l, .s, .p, .h and .o files
  72. # If any one doesn't have any members, it'll contain the original
  73. # pattern (b/c of nonomatch). We want it to be empty, though, so
  74. # we reset it.
  75. #
  76. set nonomatch
  77. set srcs=( ${pref}*.[cylsp] )
  78. if ("$srcs" == "${pref}*.[cylsp]") set srcs=()
  79. set Hfiles=( ${pref}*.h )
  80. if ("$Hfiles" == "${pref}*.h") set Hfiles=()
  81. rm -f version.o
  82. set Ofiles=( ${pref}*.o )
  83. if ("$Ofiles" == "${pref}*.o") set Ofiles=()
  84. unset nonomatch
  85.  
  86. #
  87. # Merge in any .o files that can be created from local source files but don't
  88. # exist yet. In addition, figure out which .o files may be safely removed
  89. # during a "make clean" and store them in RmOfiles.
  90. #
  91. set RmOfiles=""
  92. if ("$srcs" != "") then
  93.     foreach file ($srcs)
  94.         set file=$file:r.o
  95.         set RmOfiles=($RmOfiles $file)
  96.         if (! -e $file) set Ofiles=($Ofiles $file)
  97.     end
  98. endif
  99.  
  100. cat $proto | sed \
  101.     -e "s,@@(PROGRAM),$prog,g" \
  102.     -e "s,@@(OBJS),$Ofiles,g" \
  103.     -e "s,@@(CLEANOBJS),$RmOfiles,g" \
  104.     -e "s,@@(SRCS),$srcs,g" \
  105.     -e "s,@@(HDRS),$Hfiles,g" \
  106.     -e "s,@@(MAKEFILE),$makefile,g" \
  107.     -e "s,@@(TEMPLATE),$proto,g" \
  108.     -e "s,@@(DISTDIR),$distdir,g" \
  109.     -e "s,@@(DATE),`date`,g" > $makefile
  110. endif
  111. @
  112.  
  113.  
  114. 1.2
  115. log
  116. @New version to bring up to date with rest of mkmf stuff.
  117. @
  118. text
  119. @d26 2
  120. d74 1
  121. @
  122.  
  123.  
  124. 1.1
  125. log
  126. @Initial revision
  127. @
  128. text
  129. @d3 2
  130. a4 3
  131. # A script to generate (or regenerate) a source (cmds) directory  Makefile
  132. # from the prototype Makefile.  If ./Makefile.proto exists, use it, else
  133. # use a common prototype.
  134. d6 13
  135. a18 2
  136. set path=(/sprite/users/sprite/bin /usr/new /usr/local /usr/bin /usr/ucb /bin)
  137. rehash
  138. d20 2
  139. a21 5
  140. set root=/sprite
  141.  
  142. set cmddir=`pwd`
  143. if ($cmddir =~ /sprite/att*) then
  144.     set isAtt = 1
  145. d23 1
  146. a23 1
  147.     set isAtt = 0
  148. a24 4
  149. #set isAtt = `echo $cmddir | sed 's/\/[a-zA-Z]*\/\([a-zA-Z]*\)\/.*/\1/'`
  150. set prog=$cmddir:t
  151. set cmddir=$cmddir:h
  152. set cmddir=$cmddir:t
  153. d26 2
  154. a27 2
  155. if (-e Makefile.proto) then
  156.     set proto=Makefile.proto
  157. d29 1
  158. a29 1
  159.     set proto="${root}/src/lib/makemake/Makefile.test"
  160. d32 1
  161. a32 2
  162. /bin/echo "Generating a Makefile for the test program $prog in cmds/$cmddir"
  163. /bin/echo "Using $proto."
  164. d34 6
  165. a39 1
  166. unalias ls
  167. d41 8
  168. a48 4
  169. set Cfiles=`ls [a-z_A-Z]*.c`
  170. set Hfiles=`ls [a-z_A-Z]*.h`
  171. /bin/rm -f version.o
  172. set Ofiles=`ls [a-z_A-Z]*.o`
  173. a49 25
  174. if ("$Cfiles" != "") then
  175.     foreach file ($Cfiles)
  176.     set ofile = `echo $file | sed -e "s/\.c/.o/g"`
  177.     if (! -e $ofile) set Ofiles=($Ofiles $ofile)
  178.     end
  179. endif
  180.  
  181. # RmOfiles are files that may be removed safely.  (We can't just have
  182. # make clean remove *.o because some .o files may not be recreatable.
  183. set RmOfiles=`echo $Cfiles | sed -e "s/\.c/.o/g"`
  184.  
  185. # set Pfiles=`echo $Ofiles | sed -e "s/\.o//g"`
  186.  
  187. if (-e Makefile) /bin/mv  Makefile Makefile.$$~
  188.  
  189. if (-e ${prog}.arg) then
  190.     /bin/cat $proto | \
  191.         sed -e "s/dir-name/$cmddir/" \
  192.         -e "s/^CSRCS.*/CSRCS = $Cfiles/" \
  193.         -e "s/^HDRS.*/HDRS = $Hfiles/" \
  194.         -e "s/^OBJS.*/OBJS = $Ofiles/" \
  195.         -e "s/^RMOBJS.*/RMOBJS = $RmOfiles/" \
  196.         -e "s/^PROG.*/PROG = $prog/" \
  197.         > Makefile
  198. else
  199. d51 3
  200. a53 1
  201. #    no prog.arg file so nuke the doargs stuff by eliminating ARGOBJ
  202. d55 7
  203. a61 9
  204.     /bin/cat $proto | \
  205.         sed -e "s/dir-name/$cmddir/" \
  206.         -e "s/^CSRCS.*/CSRCS = $Cfiles/" \
  207.         -e "s/^HDRS.*/HDRS = $Hfiles/" \
  208.         -e "s/^OBJS.*/OBJS = $Ofiles/" \
  209.         -e "s/^RMOBJS.*/RMOBJS = $RmOfiles/" \
  210.         -e "s/^PROG.*/PROG = $prog/" \
  211.         -e "s/^ARGOBJ.*/ARGOBJ = /" \
  212.         > Makefile
  213. d64 9
  214. a72 7
  215. if ($isAtt) then
  216.     echo "Adding unix definitions."
  217.     mv Makefile{,.$$~~}
  218.     sed -e 's/^UNIXLIB.*/UNIXLIB = ${ATTLIB}\/unix.a/' \
  219.     -e 's/^ATTINCL.*/ATTINCL = ${ATTLIB}\/include/' \
  220.     Makefile.$$~~ > Makefile
  221.     rm Makefile.$$~~
  222. a73 14
  223.  
  224. if (-e Makefile.sed) then
  225.     echo "Modifying with Makefile.sed."
  226.     mv Makefile{,.$$~~}
  227.     sed -f Makefile.sed Makefile.$$~~ > Makefile
  228.     rm Makefile.$$~~
  229. endif
  230.  
  231. if (-e Makefile.ex) then
  232.     echo "Modifying with Makefile.ex."
  233.     ex - Makefile < Makefile.ex
  234. endif
  235.  
  236. /sprite2/users/sprite/bin/make depend
  237. @
  238.